package com.blue.excel.demo;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by ChenYaHui on 2017/8/8.
 */
public class Test2 {
    int intValue = 3;
    Integer integerValue = 3;
    long longValue = 3;
    Long longValue1 = 2L;
    short shortValue = 3;
    Short shortVal = 3;
    double doubleValue = 3;
    Double doubleVal = 32D;
    float floatValue = 3.4F;
    Float floatVal = 3.4F;
    Date date = new Date();
    Test test = new Test();
    Child child = new Child();

    public static void main(String[] args){
        Test2 test2 = new Test2();
        Field[] fields = Test2.class.getDeclaredFields();
        for(Field field : fields){
            Object obj = null;
            try {
                obj = field.get(test2);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            boolean num = isNum(String.valueOf(obj));
            System.out.println(field.getType() + " is " + (num ? "" : "not ") + "Number");
        }


    }

    public static boolean isNum(String str) {
        try {
            new BigDecimal(str);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
